﻿/**
 * @file		driver_common.h
 * @brief		Device Driver Common Definition
 * @note		None
 * @attention	None
 * 
 * <B><I>Copyright 2016 Socionext Inc.</I></B>
 */

/**
@addtogroup common
@{
*/

#ifndef _DRIVER_COMMON_H_
#define _DRIVER_COMMON_H_

#include "typedef.h"
#include "ddim_user_custom.h"

/*----------------------------------------------------------------------*/
/* Definition															*/
/*----------------------------------------------------------------------*/
/* Compile option */
#define		CO_PARAM_CHECK								/**< Compile Option of Parametre Check. */
#define		CO_MSG_PRINT_ON								/**< Compile Option of Message Print Output. */
//#define		CO_ACT_CLOCK								/**< Compile Option of Active Clock for CLK. */
//#define		CO_ACT_ICLOCK								/**< Compile Option of Active Clock for AXICLK. */
//#define		CO_ACT_PCLOCK								/**< Compile Option of Active Clock for APBCLK. */
//#define		CO_ACT_HCLOCK								/**< Compile Option of Active Clock for AHBCLK. */
#define		CO_ASSERT_ON								/**< Compile Option of Assertion. */
//#define		CO_MEMORY_DEVICE							/**< Compile Option of Memory device. */
#ifndef		CO_DDIM_UTILITY_USE
#define		CO_DDIM_UTILITY_USE							/**< Compile Option of DDIM utility. */
#endif	// CO_DDIM_UTILITY_USE

/* Device type (Upper 16bit on error code) */
/* --------- ChipTop ------------------------------- */
#define		D_DD_TOP					(0x00010000)	/**< ChipTop */

/* --------- ARM ----------------------------------- */
#define		D_DD_ARM					(0x00030000)	/**< ARM */
#define		D_DD_IPCU					(0x00040000)	/**< IPCU */

/*---------- PMC ---------------------------- */
#define		D_DD_PMC_CALENDAR			(0x00100000)	/**< Calendar function Unit */
#define		D_DD_PMC_CTC				(0x00200000)	/**< Cycle Time Counter */
#define		D_DD_PMC_CRG11				(0x00300000)	/**< Sub clock reset generator */
#define		D_DD_PMC_UART				(0x00400000)	/**< UART */
#define		D_DD_PMC_SPI				(0x00500000)	/**< SPI */
#define		D_DD_PMC_I2C				(0x00600000)	/**< I2C */
#define		D_DD_PMC_ADC				(0x00700000)	/**< A/D Convertor */
#define		D_DD_PMC_TMR32				(0x00800000)	/**< 32bit reload timer */
#define		D_DD_PMC_HDMAC				(0x00900000)	/**< DMA controller */
#define		D_DD_PMC_GPIO				(0x00A00000)	/**< GPIO */
#define		D_DD_PMC_PMU				(0x00B00000)	/**< Power Management Unit */
#define		D_DD_PMC_TS_IF				(0x00C00000)	/**< Temperature Sensor Interface */
#define		D_DD_PMC_EXIU				(0x00D00000)	/**< External Interrupt unit */
#define		D_DD_PMC_WDOG				(0x00E00000)	/**< Watchdog Timer */


/* Error definition (Lower 16bit on error code) */
#define		D_DDIM_OK					(0x00000000)	/**< Normal end */
#define		D_DDIM_INPUT_PARAM_ERROR	(0x00000001)	/**< Input parameter error */
#define		D_DDIM_EXT_LOCK_NG			(0x00000002)	/**< Lock error */
#define		D_DDIM_NO_RECEIVE			(0x00000003)	/**< No receive */
#define		D_DDIM_OVERFLOW_ERR			(0x00000004)	/**< Overflow */
#define		D_DDIM_MACRO_BUSY_NG		(0x00000005)	/**< Macro busy */
#define		D_DDIM_NO_SEND_DATA			(0x00000006)	/**< No sending data */
#define		D_DDIM_PARITY_DATA			(0x00000007)	/**< Parity data */
#define		D_DDIM_OVERRUN_DATA			(0x00000008)	/**< Over running */
#define		D_DDIM_FRAMING_DATA			(0x00000009)	/**< Framing error */
#define		D_DDIM_ACCESS_ERR			(0x0000000A)	/**< Access error */
#define		D_DDIM_PROCESSING			(0x0000000B)	/**< Job Processing  */
#define		D_DDIM_SEM_NG				(0x00000010)	/**< Semaphore acquisition NG */
#define		D_DDIM_SEM_TIMEOUT			(0x00000011)	/**< Semaphore acquisition Time Out */
#define		D_DDIM_STATUS_ABNORMAL		(0x00000012)	/**< Abnormal Status */
#define		D_DDIM_TIMEOUT				(0x00000013)	/**< Time Out */
#define		D_DDIM_OVERFLOW_OK			(0x00000017)	/**< Overflow OK */
#define		D_DDIM_DATA_EXIST_ERROR		(0x00000018)	/**< Data exist */
#define		D_DDIM_OVERWRITE_ERROR		(0x00000019)	/**< Overwrite error */
#define		D_DDIM_AXI_ERROR			(0x0000001A)	/**< AXI BUS error */
#define		D_DDIM_R_AXI_ERROR			(0x0000001B)	/**< AXI BUS error(Read ch) */
#define		D_DDIM_W_AXI_ERROR			(0x0000001C)	/**< AXI BUS error(Write ch) */
#define		D_DDIM_BUS_ERROR			(0x0000001D)	/**< BUS error */
#define		D_DDIM_ARBITRATION_LOST		(0x0000001E)	/**< Arbitration lost detect */
#define		D_DDIM_COMM_ERROR			(0x0000001F)	/**< Communication error */
#define		D_DDIM_FORCE_STOP			(0x00000020)	/**< Forced stop */
#define		D_DDIM_SYSTEM_ERROR			(0x00000099)	/**< System error */

/*----------------------------------------------------------------------*/
/* Enumeration															*/
/*----------------------------------------------------------------------*/
/* Nothing Special */

/*----------------------------------------------------------------------*/
/* Structure															*/
/*----------------------------------------------------------------------*/
/* Nothing Special */

/*----------------------------------------------------------------------*/
/* Global Data															*/
/*----------------------------------------------------------------------*/
/* Nothing Special */

/*----------------------------------------------------------------------*/
/* Macro																*/
/*----------------------------------------------------------------------*/
#ifndef Ddim_Print
#ifndef CO_MSG_PRINT_ON
#define Ddim_Print(arg)									/**< printf function inside DDIM */
#else
#include <stdio.h>
#define Ddim_Print(arg)		{DDIM_User_Printf arg;}		/**< printf function inside DDIM */
#endif	// CO_MSG_PRINT_ON
#endif	// Ddim_Print

#ifdef CO_ASSERT_ON
#define Ddim_Assertion(arg) {							\
	Ddim_Print(("!! Assert : %s (%d)", __FILE__, __LINE__));\
	Ddim_Print(arg);\
	DDIM_User_Assertion_Error();\
}														/**< assertion code */
#else
#define Ddim_Assertion(arg)
#endif	// CO_ASSERT_ON

/*----------------------------------------------------------------------*/
/* Function																*/
/*----------------------------------------------------------------------*/
/* Nothing Special */

#endif	// _DRIVER_COMMON_H_

/*@}*/
